package com.example.demo.mapper;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.Zhigong;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository()
public interface Zhigong_Mapper extends BaseMapper<Zhigong>{
	
	@Select("SELECT Zhigong.* ,bumen.bumenmingcheng bumenname"
	        + " FROM Zhigong inner join bumen on  zhigong.bumenid = bumen.id  ${where} ${limitstr}")
	public List<Zhigong> select(SearchInfo info);

	@Select("SELECT COUNT(1) FROM Zhigong ${where}")
	public long selectCount(SearchInfo info);
	
	@Insert("INSERT INTO Zhigong (name,bumenid, age, sex, dianhua) VALUES (#{name},#{bumenid}, #{age}, #{sex}, #{dianhua})")
	public void insert(Zhigong Zhigong);
	
	@Update("UPDATE Zhigong SET name = #{name},bumenid = #{bumenid}, age = #{age}, "
	        + "sex = #{sex}, dianhua = #{dianhua} WHERE id = #{id}")
	public void update(Zhigong Zhigong);
	
	
	@Delete("DELETE FROM Zhigong WHERE id = #{id}")
	public void delete(int id);
	
	@Select("SELECT * FROM Zhigong WHERE id = #{id}")
	public Zhigong selectById(int id);
	
}
